package com.svconnect.plugin.model.wsdl;

import java.util.ArrayList;
import java.util.List;

public class Operation {

	private String name;
	private List<Parameter> parameters;
	private IDataType response;
	private String action;
	private List<ComplexDataType> faults = new ArrayList<ComplexDataType>();

	public Operation() {}
	
	public Operation(String name, List<Parameter> parameters, IDataType response) {
		this.setName(name);
		this.setParameters(parameters);
		this.setResponse(response);
	}	
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Parameter> getParameters() {
		return parameters;
	}

	public void setParameters(List<Parameter> parameters) {
		this.parameters = parameters;
	}

	public IDataType getResponse() {
		return response;
	}

	public void setResponse(IDataType response) {
		this.response = response;
	}
	
	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}	
	
	public List<ComplexDataType> getFaults() {
		return this.faults;
	}
	
	public boolean addFault(ComplexDataType faultType) {
		if (faultType!=null && faultType.getType() == EComplexType.EXCEPTION) {
			this.faults.add(faultType);
			return true;
		}
		return false;
	}
	
	public void removeFault(ComplexDataType faultType) {
		if (this.faults.contains(faultType)) {
			this.faults.remove(faultType);
		}
	}
	
	
}
